package com.mmy.dao.oa;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.mmy.domain.oa.RewardInfo;

public interface RewardInfoRepository extends JpaRepository<RewardInfo, Integer> {

	/*
	 * 获取最大值id
	 */
	@Query(value = "select MAX(iRewardID) from tSysRewardInfo", nativeQuery = true)
	Object getMaxRewardID();

	/*
	 * 新增id
	 */
	@Transactional
	@Modifying
	@Query(value = "INSERT INTO tSysRewardInfo(iRewardID, iUserID, cReason, iTypeID, iMrgID, dConfirm, cMessage, dCreateDate, cCreator, dModifyDate, cReviser, cMemo, cSpare1, cSpare2, cSpare3, cSpare4, cSpare5) VALUES (:rewardID, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)", nativeQuery = true)
	void save(@Param("rewardID") int rewardID);

	/*
	 * 根据id删除
	 */
	@Transactional
	@Modifying
	@Query(value = "delete from tSysRewardInfo where tSysRewardInfo.iRewardID in (:lstRewardID)", nativeQuery = true)
	void delRewardInfo(@Param("lstRewardID") List<Integer> lstRewardID);

	/*
	 * 根据id查找
	 */
	@Query(value = "select *  from tSysRewardInfo where iRewardID = :iRewardID", nativeQuery = true)
	RewardInfo findByRewardID(@Param("iRewardID") int iRewardID);

}
